home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / GUI_LIBR.ARJ / GUI_LIB.H < prev    next >
C/C++ Source or Header  |  1992-08-13  |  7KB  |  317 lines

  1. #include <dos.h>
  2. #include <string.h>
  3. #include <graphics.h>
  4. #include <stdarg.h>
  5. #include <stdio.h>
  6.  
  7. #define TRUE 1
  8. #define FALSE 0
  9. #define IN 0
  10. #define OUT 1
  11. #define THICK 0
  12. #define THIN 1
  13. #define TEXT 0
  14. #define IMAGE 1
  15.  
  16.  
  17. //**************************   Graphic Objects   **************************
  18.  
  19. class Point
  20. {
  21.     protected:
  22.         int x,y,color;
  23.         viewporttype vref;
  24.     public:
  25.         Point();
  26.         void move(int ptx,int pty);
  27.         virtual void draw();
  28.         void create(int ptx,int pty,int c);
  29.         void restoreviewport();
  30.         void Setcolor(int c);
  31.         virtual void setloc(int ptx,int pty);
  32.         virtual void erase();
  33.         int Getcolor();
  34.         int Getx();
  35.         int Gety();
  36. };
  37.  
  38. //************************************************************************
  39.  
  40. class Colorbutton:public Point
  41. {
  42.     protected:
  43.         int color;
  44.         int width;
  45.         int height;
  46.     public:
  47.         void init(int,int,int,int,int);
  48.         void show(int);
  49.         int  hit();
  50.         int getcolor();
  51.     };
  52.  
  53. //************************************************************************
  54.  
  55. class Icon:public Point
  56. {
  57.     protected:
  58.         int state;
  59.     public:
  60.         void far *picture;
  61.         Icon();
  62.         ~Icon();
  63.         void init(int,int,char*);
  64.         void show();
  65.         void choose();
  66.         int hit();
  67.         int ispressed();
  68.     };
  69.  
  70. //************************************************************************
  71.  
  72. class Acticon:public Icon
  73. {
  74.     protected:
  75.         void *picture[32];
  76.         int state;
  77.         int numpix;
  78.     public:
  79.         Acticon();
  80.         ~Acticon();
  81.         void init(int,int,char*);
  82.         void show(int);
  83.         void choose();
  84.         int ispressed();
  85.         void animate(int);
  86.         void backforth(int);
  87.     };
  88.  
  89. //************************************************************************
  90.  
  91. class Button:public Point
  92. {
  93.     protected:
  94.         int state,sizex,sizey;
  95.         char btntxt[40];
  96.         int  file_text;
  97.         void *picture;
  98.         void getpic(char*);
  99.     public:
  100.         Button();
  101.         ~Button();
  102.         virtual void show();
  103.         virtual void press();
  104.         void init(int ptx,int pty,char* text,int);
  105.         virtual void erase();
  106.         virtual void move(int ptx,int pty);
  107.         void setstate(int bstate);
  108.         void invert();
  109.         int hit();
  110. };
  111.  
  112. //************************************************************************
  113.  
  114. class Panel:public Point
  115. {
  116.     protected:
  117.         int w;
  118.         int h;
  119.         int in_or_out;
  120.         int thick_or_thin;
  121.     public:
  122.         Panel();
  123.         ~Panel();
  124.         virtual void show();
  125.         void init(int,int,int,int,int,int);
  126. };
  127.  
  128. //************************************************************************
  129.  
  130. class Bevel:public Point
  131. {
  132.     private:
  133.         int w;
  134.         int h;
  135.         int thick_or_thin;
  136.         Panel outerbevel;
  137.         Panel innerbevel;
  138.     public:
  139.         void init(int,int,int,int,int);
  140.         virtual void show();
  141. };
  142.  
  143. //*******************************   Graphics Menus  **********************
  144.  
  145. typedef char gitemarray[80][10];
  146.  
  147. class Gmenu {
  148.     protected:
  149.         int on;
  150.         int x,y,w,h;
  151.         int num;
  152.         gitemarray gitems;
  153.         int menuchoice;
  154.         int oldbarx,oldbary;
  155.         void *ptr;
  156.         void *menubar;
  157.     public:
  158.         Gmenu();
  159.         ~Gmenu();
  160.         void init(int xloc,int yloc,int numentries,gitemarray gitem);
  161.         int show();
  162.         void hide();
  163.         int isshown();
  164. };
  165.  
  166. //*************************************************************************
  167.  
  168. class Gmenubutton {
  169.     protected:
  170.         int on;
  171.         int x,y;
  172.         int offfgd,offbgd;
  173.         int onfgd,onbgd;
  174.         char id[20];
  175.     public:
  176.         Gmenubutton();
  177.         ~Gmenubutton();
  178.         void init(int xloc,int yloc,int ffgd,int fbgd,int nfgd,int nbgd,char txt[20]);
  179.         void show();
  180.         void press();
  181.         int hit();
  182. };
  183.  
  184. //*****************************   Graphic text output   *******************
  185.  
  186. void gprintf(int *xloc,int *yloc,char *fmt,...);
  187. void gprintc(int *xloc, int *yloc, char *fmt,...);
  188. void gprintxy(int xloc,int yloc,char *fmt,...);
  189.  
  190. //************************  Library Support functions  *********************
  191.  
  192. void vprintat(int cols,int rows,int fore,int back,char *,...);
  193. void vprintc(int row,int fore,int back,char *,...);
  194. void printat(int,int,int,int,char *);
  195. void printc(int,int,int,char *);
  196. void cprintat(int,int,int,int,char *,...);
  197. void cprintc(int,int,int,char *,...);
  198. void clear(char ch,int fore,int back);
  199. void cursoroff();
  200. void cursoron();
  201. void settext(int,int);
  202. void chsattr(int,int);
  203. void chcattr(int,int,int,int,int);
  204. void dlay(int ticks);
  205. long getticks();
  206. unsigned char getvidmode();
  207. void screenbord(int);
  208. int altkey();
  209. int ctrlkey();
  210. int lshiftkey();
  211. int rshiftkey();
  212. void disable_blink();
  213. void enable_blink();
  214. void disable_refresh();
  215. void enable_refresh();
  216. void flushkeys();
  217.  
  218.  
  219. //*************************** String Objects   ****************************
  220.  
  221. class Tstring {
  222.     protected:
  223.         char laststring[81];
  224.         char bar[81];
  225.         int xpos;
  226.         int x;
  227.         int y;
  228.         int length;
  229.         int ucase;
  230.         int escape;
  231.         int retrn;
  232.         int tab;
  233.         int uparrow;
  234.         int dnarrow;
  235.         int shown;
  236.         int barred;
  237.         int firstchar;
  238.         int infgd;
  239.         int inbgd;
  240.     public:
  241.         Tstring();
  242.         ~Tstring();
  243.         void init(int xloc,int yloc,int len,int uppercase);
  244.         void show();
  245.         void input();
  246.         void get_input();
  247.         void get_form_input();
  248.         void get_form_mouse_input();
  249.         void reset();
  250.         void preset(char *);
  251.         void erase(int);
  252.         char *getstring();
  253.         int escapehit();
  254.         int returnhit();
  255.         int tabhit();
  256.         int uparrowhit();
  257.         int dnarrowhit();
  258.         int isshown();
  259.         int isbarred();
  260.         int hit();
  261.         void setincolors(int,int);
  262. };
  263.  
  264. //**************************************************************************
  265.  
  266. class Gstring:public Tstring {
  267.     protected:
  268.         int curpos;
  269.         int curson;
  270.         void showcurs();
  271.         void hidecurs();
  272.     public:
  273.         void init(int,int,int,int);
  274.         void show();
  275.         void input();
  276.         void get_input();
  277.         void get_form_input();
  278.         void reset();
  279.         int isshown();
  280.         void check_for_blink();
  281. };
  282.  
  283. //************************  Mouse functions  ******************************
  284.  
  285. typedef struct {
  286.         int m1,m2,m3,m4;
  287.         } mparams;
  288.  
  289.  
  290. void mouse(mparams *p);
  291.  
  292. extern int _Cdecl button;
  293. extern int _Cdecl status;
  294. extern int _Cdecl count;
  295. extern int _Cdecl xpos;
  296. extern int _Cdecl ypos;
  297.  
  298. int mouse_init(void);
  299. void show_cursor(void);
  300. void hide_cursor(void);
  301. void get_status(int *button, int *curx, int *cury);
  302. void pos_mouse(int x, int y);
  303. void b_press(int btn, int *bnow, int *bcount, int *x, int *y);
  304. void sethbounds(int l, int r); /* set left and right boundaries */
  305. void setvbounds(int t, int b); /*set top and bottom bounds */
  306. void setgraphics(int hspot, int vspot, void far *cmask);
  307. void setspeed(int x, int y);
  308. void set_threshold(int);
  309. void set_subroutine(int,void (far *)(void));
  310. void b_release(int,int *,int *,int *,int *);
  311. void settext(int,int,int);
  312. void motion(int *,int *);
  313. void light_pen(int);
  314. void conditional_off(int,int,int,int);
  315. int leftmousekeypressed();
  316. int rightmousekeypressed();
  317.